package com.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

public class LogUtil {

	/**
	 * @return
	 */
	public static List<String> getErrorCodes() {
		List<String> errorCodeList = new ArrayList<String>();
		// load a properties file
		// get the property value and print it out
		String errorCodes = getValueFromProperties(
				"ErrorCodeConfig.properties", "errorcodes");
		errorCodeList = Arrays.asList(errorCodes.split(","));
		return errorCodeList;
	}

	public static void main(String[] args) {
		System.out.println(LogUtil.getErrorCodes());
	}

	/**
	 * @return
	 */
	public static String getValueFromProperties(final String propertiesFile,
			final String key) {
		Properties prop = new Properties();
		String value = "";
		File file = new File(propertiesFile);
		try {
			// load a properties file
			prop.load(new FileInputStream(file));
			// get the property value and print it out
			value = prop.getProperty(key);
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		return value;
	}
}
